<template>
  <el-table :data="watchChaoDi"
            style="width: 100%"
            height="100%">
    <el-table-column prop="name" min-width="20%" label="名称"></el-table-column>
    <el-table-column prop="level" min-width="20%" label="级别"></el-table-column>
    <el-table-column prop="price" min-width="20%" label="价格"></el-table-column>
    <el-table-column prop="count" min-width="20%" label="数量"></el-table-column>
    <el-table-column label="类型" min-width="25%">
      <div slot-scope="scope">
        {{ scope.row.type === 1 ? "定投" : "做T" }}
      </div>
    </el-table-column>
    <el-table-column prop="date" min-width="30%" label="时间"></el-table-column>
  </el-table>
</template>
<script>
import {recording} from '../utils/request'

export default {
  data() {
    return {
      watchChaoDi: [],
      filters: [],
      timer: null
    }
  },
  created() {
    this.getInfo();
    this.timer = setInterval(() => {
      this.getInfo();
    }, 5000)
  },
  methods: {
    getInfo() {
      recording().then((res) => {
        this.watchChaoDi = res.content;
      })
    },
    //方法区
    formatDate(row, column) {
      // 获取单元格数据
      let data = row[column.property]
      if (data == null) {
        return null
      }
      let dt = new Date(data)
      return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate();
    },
  },
  beforeDestroy() {
    clearInterval(this.timer);
  }
}
</script>
